import Taro from '@tarojs/taro'
import { sendSmsCode,checkSmsCode } from './service';


export default {
  namespace: 'login',
  state: {},
  effects: {
    * send({payload:phone}, { call }) {
      console.log('login effect phone',phone);
      const response = yield call(sendSmsCode,phone)
      console.log('login effect response',response);
    },
    * login ({payload:{phone,code}},{call}){
      console.log('login effect code',code);
      console.log('login effect phone',phone);
      const response = yield call(checkSmsCode,{phone,code})
      console.log('lgoin effect login response',response);
      if (response) {
        1
      } else {
        Taro.switchTab({ url:'../home/index' })
      }
    }
  },
};
